// trace of a matrix

# include <iostream>
using namespace std;

class TraceFinder {
  int row, i, j;
  int a[10][10];
public:
  void get();
  void printTrace();
};

void TraceFinder::get() {
  cout << "Enter rows/columns for the matrix: ";
  cin >> row;
  cout << "\n";
  for(i = 0; i < row; i++) {
    for(j = 0; j < row; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "]: " ;
      cin >> a[i][j];
    }
  }
}

void TraceFinder::printTrace() {
  int trace = 0;
  for(i = 0; i < row; i++) {
    trace += a[i][i];
  }
  cout << "Trace of the matrix is: " << trace << "\n";
}

int main() {
  TraceFinder tf;
  tf.get();
  tf.printTrace();
}
